﻿create procedure dbo.GetAudiences
(
		@PortalID int
		
	)
AS
set nocount on

-- first result return audinences

SELECT     Id, Name, Description, [SiteID]
FROM         dbo.Audience
WHERE     ([SiteID] = @PortalID)

-- second return audience members

SELECT     dbo.AudienceMembers.UserID, dbo.AudienceMembers.AudienceId, dbo.AudienceMembers.CreatedOn
                FROM         dbo.Audience INNER JOIN
                                      dbo.AudienceMembers ON dbo.Audience.Id = dbo.AudienceMembers.AudienceId
                WHERE     (dbo.Audience.[SiteID] = @PortalID)


